package cn.aiweiyi.qingjing.coupon.distribution.feign;

import cn.aiweiyi.qingjing.coupon.comm.vo.CommonResponse;
import cn.aiweiyi.qingjing.coupon.comm.vo.CouponTemplateSDK;
import cn.aiweiyi.qingjing.coupon.distribution.feign.hystrix.TemplateClientHystrix;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;
import java.util.Map;


/**
 * 用于对优惠券tempalte服务进行调用feign接口定义
 */
@FeignClient(value = "eureka-client-coupon-template",
        url = "http://localhost:7001/",
        fallback = TemplateClientHystrix.class)//指定一个兜底(降级)策略实现类
public interface TemplateClient {

    @RequestMapping(value = "/coupon-template/template/sdk/all",
            method = RequestMethod.GET)
    CommonResponse<List<CouponTemplateSDK>> findAllUsableTemplate();


    @RequestMapping(value = "/coupon-template/template/sdk/infos",
            method = RequestMethod.GET)
    CommonResponse<Map<Integer, CouponTemplateSDK>> findIds2TemplateSDK(
            @RequestParam("ids") Collection<Integer> ids);

}
